<?php

namespace think;

use think\PHPMailer;

class Qmail
{
    function sendMail($toMail, $toName, $subject, $message, $attachment = null)
    {
        $mailer = new PHPMailer();

        $mailer->CharSet = "UTF-8";
        $mailer->isSMTP();
        $mailer->IsHTML(true); // set email format to HTML //是否使用HTML格式
        $mailer->SMTPDebug = 0;
        $mailer->Debugoutput = 'html';
        $mailer->Host = "smtp.qq.com";
        $mailer->Port = 25;
        $mailer->SMTPAuth = true;
        $mailer->Username = '2279384021@qq.com';
        $mailer->Password = "kjjqapgmzimoebag";
        $mailer->AddAddress = "2279384021@qq.com";
        $mailer->setFrom("2279384021@qq.com", "未来技术");

        $mailer->AddAddress($toMail, $toName);
        $mailer->Subject = $subject;
        $mailer->msgHTML($message);

        if (!$mailer->send()) { // 发送
            return $mailer->ErrorInfo;
        } else {
            return true;
        }
    }
}
